<?php
class Admin_Form_InsertProduct extends Zend_Form{
	public function init(){
		
		
		$this->setAttrib('id', 'frmAdminForm');
		$product_id = $this->createElement('text', 'product_id');
		
		$product_name = $this->createElement('text', 'product_name');
		$product_name->setLabel('Tên sản phẩm')->setRequired(true);
		
		$product_price = $this->createElement('text', 'product_price')->setLabel('Giá');
		$product_price->setRequired(true)->addValidator('digits',false);
        $product_price->setAttrib('class','price');
		//$product_price->setAttrib('onkeyup','javascript:this.value=Comma(this.value);');
		
		
		$product_price_old  = $this->createElement('text','product_price_old')->setLabel('Giá cũ');
		$product_price_old->addValidator('digits',false);
		$product_price_old->setAttrib('class','price');
		//$product_price_old->setAttrib('onkeyup','javascript:this.value=Comma(this.value);');
		
		//khuyến mãi
		$product_saleoff_status = $this->createElement('select','product_saleoff_status')->setLabel('Khuyến mãi');
		$product_saleoff_status->addMultiOptions(
				array(0=>"Tắt",1=>"Bật")
		);
		
		$product_saleoff_begin = $this->createElement('text','product_saleoff_begin')
			->setLabel('Ngày bắt đầu')
			->setAttrib('class', 'datepicker')
		;
// 		$product_saleoff_begin->setDecorators(array(
// 				'ViewHelper',
// 				'Description',
// 				'Errors',
// 				array(array('data'=>'HtmlTag'),array('tag'=>'div')),
// 				//array(array('td' => 'HtmlTag'), array('tag' => 'p')),
// 				array('Label',array('tag'=>'div')),
// 				//array(array('row'=>'HtmlTag'),array('tag'=>'div','openOnly'=>true,'class'=>'row'))
// 		));
		$product_saleoff_end = $this->createElement('text','product_saleoff_end')
			->setLabel('Ngày kết thúc')
			->setAttrib('class', 'datepicker')
		;
// 		$product_saleoff_end->setDecorators(array(
// 				'ViewHelper',
// 				'Description',
// 				'Errors',
// 				array(array('data'=>'HtmlTag'),array('tag'=>'div')),
// 				array('Label',array('tag'=>'div')),
// 				array(array('row'=>'HtmlTag'),array('tag'=>'div','closeOnly'=>true))
// 		));
		//phân loại
		$product_category_id = $this->createElement('select', 'product_category_id');
		$product_category_id->setLabel('Phân loại');
		$categoryMD = new Application_Model_DbTable_Category();
		$product_category_id->addMultiOptions($categoryMD->getPairColumn());
		
		//Hãng sản xuất
		$product_manufacture_id = $this->createElement('select', 'product_manufacture_id');
		$product_manufacture_id->setLabel('Hãng sản xuất');
		$manufactureMD = new Application_Model_DbTable_Manufacture();
		$product_manufacture_id->addMultiOptions($manufactureMD->getPairColumn());	
		
		//Hình ảnh
		$product_image = $this->createElement('image', 'product_image')->setLabel('Hình ảnh hiện tại');
		$product_image->setAttrib('onclick','javascript:return false;');
		
		$product_file = $this->createElement('file', 'file')->setLabel('Chọn hình ảnh đại diện cho sản phẩm');
		$product_file->addValidator('Extension',false,'jpg,png,gif');
		$product_file->setDestination(PUBLIC_PATH.'/uploads/images/products/tmp');
		$product_file->setDescription('<a href="#" class="more-image">Nhập thêm nhiều hình ảnh</a>');
		$product_file->getDecorator('Description')->setOptions(array('escape'=>false,'tag'=>'span'));
		//$product_more_image = $this->createElement('text','product_more_image');
		//$product_more_image->setLabel('Nhập thêm nhìu hình ảnh');
		//$product_more_image->setDescription('<a href="#">Nhập</a>');

		
		//Thời gian cập nhật
		$product_creation_time = $this->createElement('text', 'product_creation_time');
		$product_creation_time->setLabel('Thời gian cập nhật');
		$product_creation_time->setAttrib('class', 'datepicker');
		
		$product_describe_vi = $this->createElement('textarea', 'product_describe_vi');
		$product_describe_vi->setLabel("Bài viết tiếng việt");
		
		$product_describe_en = $this->createElement('textarea', 'product_describe_en');
		$product_describe_en->setLabel('Bài viết tiếng anh');
		
		$product_status = $this->createElement('select','product_status')->setLabel('Trạng thái');
		$product_status->addMultiOptions(
				array(0=>"Ẩn",1=>"Hiển thị")
		);
		
		$product_hot = $this->createElement('select', 'product_hot')->setLabel('Sản phẩm hot');
		$product_hot->addMultiOptions(
				array(0=>"Không",1=>"có")
		);
		
		$product_cpu = $this->createElement('text', 'product_cpu')->setLabel('Cpu - Vi xử lý');
		
		$product_ram = $this->createElement('text', 'product_ram')->setLabel('Ram');
		
		$product_hdd = $this->createElement('text', 'product_hdd')->setLabel('Hdd - Bộ nhớ trong');
		
		$product_display = $this->createElement('text', 'product_display')->setLabel('Display - Màn hình');
		
		//card màn hình
		$product_video_card = $this->createElement('text', 'product_video_card')->setLabel('Card màn hình');
		
		$product_operator = $this->createElement('text', 'product_operator')->setLabel('Operator - Hệ điều hành');
		
		$product_camera = $this->createElement('text', 'product_camera')->setLabel('Camera - chụp ảnh');
		
		//camera phụ
		$product_camera_sub = $this->createElement('text', 'product_camera_sub')->setLabel('Camera - phụ');
		
		$product_connect = $this->createElement('text', 'product_connect')->setLabel('Chuẩn kết nối');
		
		//tai nghe
		$product_ear_plugin = $this->createElement('text', 'product_ear_plugin')->setLabel('Tai nghe');
		
		//pin
		$product_battery = $this->createElement('text', 'product_battery')->setLabel('Pin');
		
		$product_touch = $this->createElement('text', 'product_touch')->setLabel('Cảm ứng?');
		
		
		$this->addDisplayGroup(array(
				$product_name,
				$product_category_id,
				$product_manufacture_id,
				$product_price,
				$product_price_old,
				$product_saleoff_status,
				$product_saleoff_begin,
				$product_saleoff_end,
				$product_status,
				$product_hot,
				$product_image,
				$product_file,
				//$product_more_image
		), 'basic-info',array('legend'=>'Thông tin cơ bản','class'=>'display-group'));
		
		$this->addDisplayGroup(array(
				
				$product_cpu,
				$product_ram,
				$product_hdd,
				$product_video_card,
				$product_display,
				$product_operator,
				$product_camera,
				$product_camera_sub,
				$product_ear_plugin,
				$product_battery,
				$product_connect,
				$product_touch,
				$product_describe_vi,
				$product_describe_en
		), 'detail-info',array('legend'=>'Thông tin chi tiết','class'=>'display-group'));
		
		$this->addElements(array(
				//$product_id,
				$product_name,
				$product_category_id,
				$product_manufacture_id,
				$product_price,
				$product_price_old,
				$product_saleoff_status,
				$product_saleoff_begin,
				$product_saleoff_end,
				$product_status,
				$product_hot,
				//hình ảnh trong update
				$product_image,				
				//file upload
				$product_file,
				//$product_more_image,
				//thời gian
				//$product_creation_time,
				$product_cpu,
				$product_ram,
				$product_hdd,
				$product_video_card,
				$product_display,
				$product_operator,
				$product_camera,
				$product_camera_sub,
				$product_ear_plugin,
				$product_battery,
				$product_connect,
				$product_touch,
				$product_describe_vi,
				$product_describe_en
		));
	}
}















